package com.ldp.designpatterns.study.proxy.proxyService;

import com.ldp.designpatterns.study.proxy.service.Image;
import com.ldp.designpatterns.study.proxy.service.RealImage;

/**
 * @ClassName ProxyImag
 * @Description TODO: 代理模式——代理图像类(代理对象，它充当了原始对象的替代品，以控制对原始对象的访问)
 * @Author lindipei
 * @Date 2023/10/17 17:31
 */
public class ProxyImage implements Image {
    private RealImage realImage;
    private String filename;

    public ProxyImage(String filename) {
        this.filename = filename;
    }


    @Override
    public void display() {
        if (realImage == null) {
            realImage = new RealImage(filename);
        }
        realImage.display();
    }

}
